package com.bank.controller.bank;

import com.bank.entity.BankVip;
import com.bank.entity.user.UserXx;
import com.bank.service.bank.BankServicve;
import com.bank.utils.ParamCondition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

//@RestController
@Controller
@RequestMapping("/bank")
public class BankController {

    @Autowired
    private BankServicve bankServicve;

    /**
     * 访问index界面
     * @return
     */
    @RequestMapping("index")
    public String toindex(){
        return "index";
    }


    /*
    5.21 查看待审核列表界面
     */
    @RequestMapping("daishenh")
    public String daishenh(Map map, ParamCondition p){
        int count=bankServicve.countBank();
        p.setPageSize(3);
        p.setTotal(count);
        List<BankVip> list = bankServicve.selectBank(p);
        map.put("list",list);
        map.put("p",p);
        return "dsh";
    }

    /*
    5.21 通过客户电话查询个人具体信息详情
     */
    @RequestMapping("xiangqing")
    public String xiangqing(String khdh,Map<String,Object> map){
        UserXx user=bankServicve.getOneUserXx(khdh);
        map.put("u",user);
        System.out.println(user);
        return "xiangqing";
    }

    /*
   5.24 通过客户电话查询个人具体信息详情
    */
    @RequestMapping("wtgxiangqing")
    public String wtgxiangqing(String khdh,Map<String,Object> map){
        UserXx user=bankServicve.getOneUserXx(khdh);
        map.put("u",user);
        System.out.println(user);
        return "user/wtgxq";
    }
    /*
    5.22 通过电话修改状态确定是否审核成功(成功)
     */
    @RequestMapping("wfk")
    public String wfk(String khdh){
        System.out.println(khdh);
        bankServicve.updatetg(khdh);
        return "redirect:/bank/daishenh";
    }
    /*
   5.22 通过电话修改状态确定是否审核成功(未成功)
    */
    @RequestMapping("wtg")
    public String wtg(String khdh){
        System.out.println(khdh);
        bankServicve.updatewtg(khdh);
        return "redirect:/bank/daishenh";
    }


    /*
  5.22 通过状态(1)获取待放款的集合
   */
    @RequestMapping("toweifangkuan")
    public String toweifangkuan(Map<String,Object> map,ParamCondition p){
        int count=bankServicve.countBankwfk();
        p.setPageSize(3);
        p.setTotal(count);
        List<BankVip> list = bankServicve.selectwfk(p);
        map.put("p",p);
        map.put("wfklist",list);
        return "wfk";
    }

    /*
5.22 通过状态(2)获取未通过的集合
 */
    @RequestMapping("weitongguo")
    public String weitongguo(Map<String,Object> map,ParamCondition p){
        int count=bankServicve.countBankwtg();
        p.setPageSize(3);
        p.setTotal(count);
        List<BankVip> list = bankServicve.selectwtg(p);
        map.put("wtglist",list);
        map.put("p",p);
        return "user/shwtg";
    }

    /*
    5.23 通过客户电话查询未放款个人具体信息详情
     */
    @RequestMapping("fkxq")
    public String fkxq(String khdh,Map<String,Object> map){
        UserXx user=bankServicve.getOneUserXx(khdh);
        map.put("u",user);
        System.out.println(user);
        return "user/fkxq";
    }

    /*
  5.24 通过电话修改状态确定放款(成功)
   */
    @RequestMapping("fk")
    public String fk(String khdh){
        System.out.println(khdh);
        bankServicve.updatefk(khdh);
        return "redirect:/bank/toweifangkuan";
    }

    /*
  5.24 通过状态(3)获取已放款的集合
   */
    @RequestMapping("yifangk")
    public String yifangk(Map<String,Object> map,ParamCondition p){
        int count=bankServicve.countBankyfk();
        p.setPageSize(3);
        p.setTotal(count);
        List<BankVip> tglist = bankServicve.selectyfk(p);
        map.put("tglist",tglist);
        map.put("p",p);
        return "user/fktg";
    }

}
